$(function () {
    $('#login').click(function () {
        let username = $('#username').val()
        let password = $('#password').val()
        if (!username || !password) {
            layer.msg('账号密码不能为空,请重新输入')
            return
        }
        $.ajax({
            url: '/admin/user/login',
            type: 'post',
            data: { username, password },
            success(res) {
                if (res.code === 200) {
                    localStorage.setItem('token',res.token)
                    location.href = 'index.html'
                }
            }
        })
    })
    
})